Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't mix Vite plugins when spawning temporary Vite server #6368

Merged
merged 11 commits into from
Feb 27, 2023

Conversation

userquin
Copy link
Contributor

@userquin userquin commented Feb 25, 2023

Changes

Testing

Added simple test with disparate plugins for static build.

Docs

Bug fix only: maybe we need to add some hints for integrations registering plugins, check for example @vite-pwa/astro integration logic: https://github.com/vite-pwa/astro/blob/main/src/index.ts#L31

@changeset-bot
Copy link

changeset-bot bot commented Feb 25, 2023

🦋 Changeset detected

Latest commit: fdce124

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Feb 25, 2023
@userquin
Copy link
Contributor Author

We need the command, not the mode.

@userquin
Copy link
Contributor Author

for preview, integrations should take care, and for vite user plugins we should also filter them before starting Vite preview

@userquin
Copy link
Contributor Author

don't merge yet, preparing test

@userquin
Copy link
Contributor Author

userquin commented Feb 25, 2023

We've another problem, when a plugin is included it can be excluded on sync call since we don't have command/action when using apply with function, we need to review it.

You can check this line https://github.com/withastro/astro/blob/main/packages/astro/src/core/build/index.ts#L85, Astro creates vite for build then before run the build Astro creates a new config for sync.

EDIT: seems to be ok now, I'll update the test again, I was using apply function arguments wrong 😬 ...

} else {
result = vite.mergeConfig(result, settings.config.vite || {});
}
}
Copy link
Contributor Author

@userquin userquin Feb 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add else case without plugins?

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix and awesome test!

Test failure is unrelated.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against the change, but I'd like to see better comments

packages/astro/src/core/create-vite.ts Outdated Show resolved Hide resolved
packages/astro/src/core/create-vite.ts Show resolved Hide resolved
Copy link
Contributor

@bholmesdev bholmesdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some suggestions too clear up in-line comments. Great fix though, was unaware Vite plugins have an apply utility!

packages/webapi/mod.d.ts Show resolved Hide resolved
packages/astro/src/core/create-vite.ts Outdated Show resolved Hide resolved
userquin and others added 2 commits February 27, 2023 21:37
@natemoo-re natemoo-re merged commit 02a7266 into withastro:main Feb 27, 2023
@userquin userquin deleted the fix-vite-plugins-6364 branch February 27, 2023 21:26
@astrobot-houston astrobot-houston mentioned this pull request Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running Vite server during build breaks plugin assumptions
4 participants